﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace TopShooter.Editor.Actions
{
	public class DeleteEntityAction : EditorAction
	{
		public List<Entity> Entities;


		public DeleteEntityAction(List<Entity> entities)
		{
			Entities = new List<Entity>(entities);
		}
		

		protected override bool OnApply(Scene scene)
		{

			foreach (Entity e in Entities)
			{
				e.RemoveFromScene();
			}
			return true;
			
		}

		protected override void OnUndo(Scene scene)
		{

			foreach (Entity e in Entities)
			{
				e.AddToScene(scene, e.Location);
				//e.IsSelected = true;
				//GameEditorPlayer.Instance.Selections.SelectedEntities.Add(e);
			}

		}

		protected override void AdjustLocation(int minColumn, int minRow)
		{
			foreach (Entity e in Entities)
			{
				Vector2 v = e.Location;
				v.X -= minColumn * Tile.Size.X;
				v.Y -= minRow * Tile.Size.Y;
				e.Location = v;
			}
		}
	}
}
